*** Beyond the Machine: Clientelist Brokers and Interest Organizations in Latin America
*** Alisha C. Holland and Brian Palmer-Rubin

*** Data come from LAPOP AmericasBarometer 2010 and 2012 wave
*** See accompanying merged dataset, BeyondtheMachine.dta

*** VARIABLE CONSTRUCTION

*** Client: "1" if offered something in exchange for vote, "0" otherwise
generate client = 1 if clien1==2|clien1==1
replace client=0 if clien1==3

*** Civic: "1" for each category of participation, "0" otherwise

generate problem = 0 if cp5==4 
replace problem =1 if cp5==3
replace problem =2 if cp5==2
replace problem = 3 if cp5==1

generate church = 0 if cp6==4 
replace church =1 if cp6==3
replace church =2 if cp6==2
replace church = 3 if cp6==1

generate school = 0 if cp7==4 
replace school =1 if cp7==3
replace school =2 if cp7==2
replace school = 3 if cp7==1

generate improv = 0 if cp8==4 
replace improv=1 if cp8==3
replace improv =2 if cp8==2
replace improv = 3 if cp8==1

generate prof = 0 if cp9==4 
replace prof = 0 if cp9==4 
replace prof=1 if cp9==3
replace prof =2 if cp9==2
replace prof = 3 if cp9==1

generate mother = 0 if cp20==4 
replace mother = 0 if cp20==4 
replace mother=1 if cp20==3
replace mother =2 if cp20==2
replace mother = 3 if cp20==1

generate civic = (problem >0) + (church >0)+ (school >0) +(prof>0) + (improv>0) +(mother>0)

*** Deciles of civic participation 
gen civic_decile = .
levelsof pais, local(temppais)
foreach i in `temppais' {
xtile decile_temp=civic if pais==`i', nq(10)
replace civic_decile = decile_temp if missing(civic_decile)
drop decile_temp
}
rename civic_decile civicd

*** Income: Deciles of logged real income (to account for different number of measurement categories btw 2010 and 2012)
gen size_decile = .
levelsof pais, local(temppais)
foreach i in `temppais' {
xtile decile_temp=lincome if pais==`i', nq(10)
replace size_decile = decile_temp if missing(size_decile)
drop decile_temp
}
rename size_decile lincomed

*** Consumption: Deciles based on PCA for durable goods questions
sort pais
by pais: pca r1 r3 r4 r4a r5 r6 r7 
predict consumption, score
gen pconsump= .
levelsof pais, local(temppais)
foreach i in `temppais' {
xtile consump_temp=consumption if pais==`i', nq(10)
replace pconsump = consump_temp if missing(pconsump)
drop consump_temp
}

*** Socioeconomic Controls
*** Age
generate age = q2
replace age = .a if q2>800

*** Education (in years)
replace ed = .a if ed> 80

*** Urban 
generate urban = 0 if ur == 2
replace urban = 1 if ur == 1

*** Sex ("1" if female, "0" if male)
generate sex = 1 if q1==2
replace sex = 0 if q1==1
replace sex=.a if q1==.a

*** Year Dummy
generate yeard = 1 if year==2012
replace yeard = 0 if year == 2010

*** Potential Omitted Variables

** Partisan: "1" for each type of partisan participation, "0" otherwise
generate party = 0 if cp13==4 
replace party= 0 if cp13==4 
replace party=1 if cp13==3
replace party =2 if cp13==2
replace party = 3 if cp13==1

generate campaign = 0 if pp2==2
replace campaign = 0 if pp2==2
replace campaign = 1 if pp2==1

generate partisan = (party>0) + (campaign >0)

*** Interest: Higher values for more interest in politics
generate interest = 0 if pol1==4
replace interest = 1 if pol1==3
replace interest =2 if pol1==2
replace interest=3 if pol1==1
replace interest = .a if pol1 >5 

*** Trust: Higher values for more trust in neighbors
generate trust = 0 if it1==4 
replace trust = 0 if it1==4 
replace trust=1 if it1==3
replace trust =2 if it1==2
replace trust = 3 if it1==1

*** Reliable: Index for self-reported characteristics of reliability
** per3: responsible and disciplined > 4 
** per7: generous and warm > 4 
** per8: NOT disorganized and sloppy < 4
generate reciprocal = (per3>4) + (per7>4)+ (per8<4)


*** PREDICTED PROBABILITIES USING CLARIFY

*** Change in civic participation
preserve
estsimp logit client civic lincomed urban female age ed
setx mean
setx female 1 civic 0 urban 1
simqi, prval(1)
*** A typical woman who participates in no organizations has a 8% predicted probability of vote buying offer 
setx civic 6
simqi, prval(1)
*** A typical woman at the highest level of participation has a 32% predicted probability of vote buying offer 
restore

*** Change in consumption decile
preserve
estsimp logit client civic pconsump urban female age ed
setx mean
setx female 1 urban 1
setx pconsump p10
simqi, prval(1)
*** A typical woman in the bottom decile has a 16% predicted probability of vote buying offer 
setx pconsump p90
simqi, prval(1)
*** A typical woman in the top decile has a 13% predicted probability of vote buying offer 
restore

*** Figure 1 was made by repeating this process changing the decile of each variable.  The results were graphed in R.  
*** Given that civic only has 6 categories, we used the smoothed civic decile variable for comparison sake.  

preserve
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban 1
forvalues civicd=1/10{
setx civicd `civicd'  
display "civicd = `civicd'"
simqi, prval(1)
}
restore

preserve
estsimp logit client civicd pconsump urban female age ed
setx mean
setx female 1 urban 1
foreach pconsump in p10 p20 p30 p40 p50 p60 p70 p80 p90 p99 {
setx pconsump `pconsump'  
display "pconsump =`pconsump'"
simqi, prval(1)
} 
restore

preserve
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban 1
foreach lincomed in p10 p20 p30 p40 p50 p60 p70 p80 p90 p99 {
setx lincomed `lincomed'  
display "lincomed =`lincomed'"
simqi, prval(1)
} 
restore

*** Figure 2 also was made in Clarify running country-specific regresions (ex. Argentina).
*** The results were graphed in R. 

preserve
keep if country =="Argentina"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban1
forvalues civicd=1/10{
setx civicd `civicd'  
display "civicd = `civicd'"
simqi, prval(1)
}

preserve
keep if country =="Argentina"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban 1
forvalues lincomed=1/10 {
setx lincomed `lincomed'  
display "lincomed =`lincomed'"
simqi, prval(1)
} 
restore

preserve
keep if country =="Colombia"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban1
forvalues civicd=1/10{
setx civicd `civicd'  
display "civicd = `civicd'"
simqi, prval(1)
}

preserve
keep if country =="Colombia"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban 1
forvalues lincomed=1/10 {
setx lincomed `lincomed'  
display "lincomed =`lincomed'"
simqi, prval(1)
} 
restore

preserve
keep if country =="Peru"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban1
forvalues civicd=1/10{
setx civicd `civicd'  
display "civicd = `civicd'"
simqi, prval(1)
}

preserve
keep if country =="Peru"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban 1
forvalues lincomed=1/10 {
setx lincomed `lincomed'  
display "lincomed =`lincomed'"
simqi, prval(1)
} 
restore

preserve
keep if country =="Mexico"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban1
forvalues civicd=1/10{
setx civicd `civicd'  
display "civicd = `civicd'"
simqi, prval(1)
}

preserve
keep if country =="Mexico"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban 1
forvalues lincomed=1/10 {
setx lincomed `lincomed'  
display "lincomed =`lincomed'"
simqi, prval(1)
} 
restore

preserve
keep if country =="Brazil"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban1
forvalues civicd=1/10{
setx civicd `civicd'  
display "civicd = `civicd'"
simqi, prval(1)
}

preserve
keep if country =="Brazil"
estsimp logit client civicd lincomed urban female age ed
setx mean
setx female 1 urban 1
forvalues lincomed=1/10 {
setx lincomed `lincomed'  
display "lincomed =`lincomed'"
simqi, prval(1)
} 
restore

*** Predicted Probabilities Conmparing Partisan and Civic Participation
preserve
estsimp logit client civic lincomed urban female age ed partisan
*** A typical woman who participates in the maximum partisan and civic organizations has a 46% probability.
setx mean 
setx female 1 urban 1 partisan max civic 6 
simqi, prval(1)

*** A typical woman who participates in the maximum partisan and no civic organizations has a 19% probability.
setx female 1 urban 1 partisan max civic 0
simqi, prval(1)

*** A typical woman who participates in no partisan and maximum civic organizations has a 24% probability.
setx civic max partisan 0
simqi, prval(1)

*** APPENDIX

*** Civic Intensity: Alternative variable construction for intensity of participation
egen civicintensity =rsum(problem church school prof improv mother)

** Summary Statistics
sutex client civic civicintensity lincomed pconsump urban female age ed partisan trust reciprocal interest, minmax
tabstat client civic partisan, s(mean median sd count range min max) by(country)

*** Table 1: Logit Models with country and year fixed effects 
*** Controlling for Interest, Trust, and Reliability
eststo clear
eststo, title("Model 1"): quietly xi: logit client civic lincomed urban female age ed i.pais i.year
eststo, title("Model 2"): quietly xi: logit client civic lincomed urban female age ed partisan interest i.pais i.year
eststo, title("Model 3"): quietly xi: logit client civic lincomed urban female age ed partisan interest trust reciprocal i.pais i.year
eststo, title("Model 4"): quietly xi: logit client civic pconsump urban female age ed i.pais i.year
eststo, title("Model 5"): quietly xi: logit client civic pconsump urban female age ed partisan interest i.pais i.year
eststo, title("Model 6"): quietly xi: logit client civic pconsump urban female age ed partisan interest trust reciprocal i.pais i.year
eststo, title("Model 7"): quietly xi: logit client civicintensity lincomed urban female age ed partisan interest trust reciprocal i.pais i.year
eststo, title("Model 8"): quietly xi: logit client civicintensity pconsump urban female age ed partisan interest trust reciprocal i.pais i.year
esttab using beyondmachine1.tex, cells(b(star fmt(3)) se(par fmt(2))) obslast  stats(r2, fmt(3) label(R-sqr)) keep(civic lincomed pconsump urban female age ed partisan trust reciprocal interest civicintensity) label title("Vote Buying\label{impactiv}")  
 
*** Table 2: Logit Models with country and year fixed effects, using alternative civic intensity index
eststo clear
eststo, title("Model 1"): quietly xi: logit client civicintensity lincomed urban female age ed i.pais i.year
eststo, title("Model 1"): quietly xi: logit client civicintensity lincomed urban female age ed partisan i.pais i.year 
eststo, title("Model 2"): quietly xi: logit client civicintensity lincomed urban female age ed partisan trust reciprocal i.pais i.year
eststo, title("Model 1"): quietly xi: logit client civicintensity pconsump urban female age ed i.pais i.year
eststo, title("Model 1"): quietly xi: logit client civicintensity pconsump urban female age ed partisan i.pais i.year
eststo, title("Model 2"): quietly xi: logit client civicintensity pconsump urban female age ed partisan trust reciprocal i.pais i.year
esttab using beyondmachine2.tex, cells(b(star fmt(3)) se(par fmt(2))) obslast  stats(pr2, fmt(3) label(R-sqr)) keep(civicintensity lincomed pconsump urban female age ed partisan trust reciprocal) label title("Vote Buying\label{impactiv}")  
 
*** Table 3: Logit Models with country and year fixed effects, using each indicator of civic participation
eststo clear
eststo, title("Model 1"): quietly xi: logit client problem church school improv prof mother  lincomed urban female age ed i.pais i.year
eststo, title("Model 1"): quietly xi: logit client problem church school improv prof mother  lincomed urban female age ed partisan i.pais i.year
eststo, title("Model 2"): quietly xi: logit client problem church school improv prof mother  lincomed urban female age ed partisan trust reciprocal i.pais i.year
eststo, title("Model 1"): quietly xi: logit client problem church school improv prof mother  pconsump urban female age ed i.pais i.year
eststo, title("Model 1"): quietly xi: logit client problem church school improv prof mother  pconsump urban female age ed partisan i.pais i.year
eststo, title("Model 2"): quietly xi: logit client problem church school improv prof mother pconsump urban female age ed partisan trust reciprocal i.pais i.year
esttab using beyondmachine3, cells(b(star fmt(3)) se(par fmt(2))) obslast  stats(pr2, fmt(3) label(R-sqr)) keep(problem church school improv prof mother lincomed pconsump urban female age ed partisan trust reciprocal) label title("Vote Buying\label{impactiv}")  

